function ajax(url) {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest();
        xhr.open('GET', url);
        xhr.responseType = 'json';
        xhr.onload = function () {
            if (this.status === 200) {
                resolve(this.response);
            } else {
                reject(new Error(this.statusText));
            }
        };
        xhr.send();
    });
}

// ajax('./../package.json').then(res => {
//     console.log('res', res);
//     ajax('./../package.json').then(res => {
//         // ...
//     });
// }).catch(err => {
//     console.log('err', err);
// });

ajax('./../package.json').then(res => {
    console.log(1111);
    return ajax('./../package.json');
})
.then(res => {
    console.log(2222);
    return ajax('./../package.json');
})
.catch(err => {
    console.log('err', err);
});
